package de.openkanban.shared.dto;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import de.openkanban.client.ui.presenter.RequestParameterMap;
import de.openkanban.client.util.JsonConverter;

/**
 * Data Transfer Object used for transferring User information
 */
public class UserDto extends TransferObject implements RequestParameterMap {

	private Long userId;

	private String vorname;
	private String nachname;
	private String email;
	private String password;
	private String avatarUrl;
	private String namensKuerzel;

	private List<UserDto> kontakteEmailList;

	public UserDto() {
	}

	public UserDto(String jsonEingabe) {
		kontakteEmailList = new ArrayList<UserDto>();

		userId = JsonConverter.getLongValueOrNull(jsonEingabe, "userId");
		vorname = JsonConverter.getStringValueOrNull(jsonEingabe, "vorname");
		nachname = JsonConverter.getStringValueOrNull(jsonEingabe, "nachname");
		email = JsonConverter.getStringValueOrNull(jsonEingabe, "email");
		password = JsonConverter.getStringValueOrNull(jsonEingabe, "password");
		avatarUrl = JsonConverter.getStringValueOrNull(jsonEingabe, "avatarUrl");
		namensKuerzel = JsonConverter.getStringValueOrNull(jsonEingabe, "namensKuerzel");
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getVorname() {
		return vorname;
	}

	public void setVorname(String vorname) {
		this.vorname = vorname;
	}

	public String getNachname() {
		return nachname;
	}

	public void setNachname(String nachname) {
		this.nachname = nachname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getAvatarUrl() {
		return avatarUrl;
	}

	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public String getNamensKuerzel() {
		return namensKuerzel;
	}

	public void setNamensKuerzel(String namensKuerzel) {
		this.namensKuerzel = namensKuerzel;
	}

	public List<UserDto> getKontakteEmailList() {
		return kontakteEmailList;
	}

	public void setKontakteEmailList(List<UserDto> kontakteEmailList) {
		this.kontakteEmailList = kontakteEmailList;
	}

	@Override
	public String toString() {
		return "UserDto [userId=" + userId + ", vorname=" + vorname + ", nachname=" + nachname + ", email=" + email + ", password="
				+ password + ", avatarUrl=" + avatarUrl + ", namensKuerzel=" + namensKuerzel + ", kontakteEmailList="
				+ kontakteEmailList + "]";
	}

	@Override
	public Map<String, String> valuesToMap() {
		Map<String, String> userMap = new HashMap<String, String>();
		if (userId != null) {
			userMap.put("userId", userId.toString());
		}
		userMap.put("vorname", vorname);
		userMap.put("nachname", nachname);
		userMap.put("namensKuerzel", namensKuerzel);
		userMap.put("email", email);
		return userMap;
	}

}
